package com.qf.ts.platform.front.service.impl;

import com.aliyuncs.CommonRequest;
import com.aliyuncs.CommonResponse;
import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.IAcsClient;
import com.aliyuncs.exceptions.ClientException;
import com.aliyuncs.exceptions.ServerException;
import com.aliyuncs.http.MethodType;
import com.aliyuncs.profile.DefaultProfile;
import com.qf.ts.platform.commons.util.JSONUtil;
import com.qf.ts.platform.front.domain.Param;
import com.qf.ts.platform.front.service.CodeService;
import org.springframework.stereotype.Service;

@Service
public class CodeServiceImpl implements CodeService {


    @Override
    public void getCode() {
        DefaultProfile profile = DefaultProfile.getProfile("cn-hangzhou", "LTAIjv8ljBXVIWOn", "HhSDuE0dnCStVtTptNAzMx6BnCBKyq");
        IAcsClient client = new DefaultAcsClient(profile);

        CommonRequest request = new CommonRequest();
        request.setSysMethod(MethodType.POST);
        request.setSysDomain("dysmsapi.aliyuncs.com");
        request.setSysVersion("2017-05-25");
        request.setSysAction("SendSms");
        request.putQueryParameter("RegionId", "cn-hangzhou");
        request.putQueryParameter("PhoneNumbers", "13197329871");
        request.putQueryParameter("SignName", "钫圆");
        request.putQueryParameter("TemplateCode", "SMS_165380910");
        Param param = new Param("lxl","2233");
        request.putQueryParameter("TemplateParam", JSONUtil.toJson(param));
        try {
            CommonResponse response = client.getCommonResponse(request);
            System.out.println(response.getData());
        } catch (ClientException e) {
            e.printStackTrace();
        }
    }
}
